package com.teacher.pc.controller;


import com.teacher.common.CommonResult;
import com.teacher.pojo.dto.jobtask.JobTaskAddDto;
import com.teacher.pojo.dto.jobtask.JobTaskUpdateDto;
import com.teacher.pojo.vo.jobtask.JobTaskGetVo;
import com.teacher.service.IJobTaskService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学生干部任职审批表 前端控制器
 * </p>
 *
 * @author zfm
 * @since 2021-08-04
 */
@RestController
@RequestMapping("/pc/job-task")
public class JobTaskController {
    @Autowired
    private IJobTaskService iJobTaskService;


    /**
     * 发起学生干部任职审批
     *
     * @param dto
     * @return
     */
    @PostMapping
    @ApiOperation("发起学生干部任职审批 10->一类优秀 20->一类合格 30->二类优秀 40->二类合格 50->三类优秀 60->三类合格")
    public CommonResult<String> add(@RequestBody @Validated JobTaskAddDto dto) {
        return iJobTaskService.add(dto);
    }

    /**
     * 更新流程
     *
     * @param dto
     * @return
     */
    @PutMapping
    @ApiOperation("更新流程")
    public CommonResult<String> update(@RequestBody JobTaskUpdateDto dto) {
        return iJobTaskService.updateInfo(dto);
    }

    /**
     * 获取详情
     *
     * @return
     */
    @GetMapping("/{flowId}")
    @ApiOperation("获取详情")
    public CommonResult<JobTaskGetVo> getDetails(@PathVariable("flowId") Long id) {
        return iJobTaskService.getDetails(id);
    }
}

